#include "dragscrollevent.h"
 #include "dragscroll.h"
 #include "version.h"

IMPLEMENT_DYNAMIC_CLASS(sDragScrollEvent, wxCommandEvent)

const wxEventType wxEVT_S_DRAGSCROLL_EVENT = wxNewEventType();

sDragScrollEvent::sDragScrollEvent(wxEventType commandType, int id)
					 :wxCommandEvent(commandType, id) {
   
   
   
   
    m_EventTypeLabel = _T("UNKOWN");
    if ( idDragScrollAddWindow == id)
        m_EventTypeLabel = _T("EVT_S_DRAGSCROLL_ADD_WINDOW");
    if ( idDragScrollRemoveWindow == id)
        m_EventTypeLabel = _T("EVT_S_DRAGSCROLL_REMOVE_WINDOW");
    if ( idDragScrollRescan == id)
        m_EventTypeLabel = _T("EVT_S_DRAGSCROLL_RESCAN");
    if ( idDragScrollReadConfig == id)
        m_EventTypeLabel = _T("EVT_S_DRAGSCROLL_READ_CONFIG");
    if ( idDragScrollInvokeConfig == id)
        m_EventTypeLabel = _T("EVT_S_DRAGSCROLL_INVOKE_CONFIG");
}

sDragScrollEvent::sDragScrollEvent( const sDragScrollEvent& Event)
				  :wxCommandEvent(Event) {
   


	m_EventTypeLabel = Event.GetEventTypeLabel();
}

sDragScrollEvent::~sDragScrollEvent() {
   
}

bool sDragScrollEvent::PostDragScrollEvent(const cbPlugin* targetWin) {
   

    #if defined(LOGGING)
       
       
        wxString eventTypeLabel = GetEventTypeLabel();
       
        LOGIT( _T("PostDragScrollEvent type[%s]"), eventTypeLabel.c_str());
    #endif

    cbPlugin* pPlgn = (cbPlugin*)targetWin;
    if ( not targetWin )
        pPlgn = Manager::Get()->GetPluginManager()->FindPluginByName(_T("cbDragScroll"));
   

   
    if ( pPlgn )
    {
        pPlgn->AddPendingEvent( (wxEvent&)*this );
    }
    else
    {
        #if defined(LOGGING)
        LOGIT( _T("PostDragScrollEvent[%s]"), _T("Failed"));
        #endif
        return false;
    }

    return true;

}

bool sDragScrollEvent::ProcessDragScrollEvent(const cbPlugin* targetWin) {
   

    #if defined(LOGGING)
       
       
        wxString eventTypeLabel = GetEventTypeLabel();
       
        LOGIT( _T("ProcessDragScrollEvent type[%s]"), eventTypeLabel.c_str());
    #endif

    cbPlugin* pPlgn = (cbPlugin*)targetWin;
    if ( not targetWin )
        pPlgn = Manager::Get()->GetPluginManager()->FindPluginByName(_T("cbDragScroll"));

   
    if ( pPlgn )
    {
        pPlgn->ProcessEvent( (wxEvent&)*this );
    }
    else
    {
        #if defined(LOGGING)
        LOGIT( _T("ProcessDragScrollEvent[%s]"), _T("Failed"));
        #endif
        return false;
    }

    return true;

}
